package dingtalk

import (
	"encoding/json"
	"fmt"
	"proxy_resource_test/config"
)

// Send 发送消息
func Send(message string) {
	if config.AppConfig.Env == "dev" {
		fmt.Println("测试环境-----------")
		fmt.Println(message)
		fmt.Println("测试环境消息-----------")
		return
	}
	responseBody, err := PostDingTalkRobot(message, "", "")
	if err != nil {
		fmt.Println("Post DingTalk robot failed:", err.Error())
		return
	}
	var data DingTalkResponse
	err = json.Unmarshal(responseBody, &data)
	if err != nil {
		fmt.Println("Post DingTalk robot failed:", err.Error())
		return
	}
	fmt.Println("Send message to DingTalk robot success.")
}
